/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package autowus.gui.single;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;

import pl.auto.ws.EwusService;
import pl.auto.ws.Generator;
import pl.auto.ws.IEwusService;

/**
 *
 * @author Quark
 */
public class SinglePanel extends javax.swing.JPanel {

    boolean result = false;
    /**
     * Creates new form SinglePanel
     */
    public SinglePanel() {
        initComponents();
        
        checkBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evnt) {
                //result = !result;
                Generator gen = new Generator();
                gen.prepareLoginSoap("Stefan", "qwert612asd");
                String response = gen.executeCheck(peselNoTextField.getText());
                if(response.equals("UPRAWNIONA")){
                	result=true;
                }
                else{
                result=false;
                }
                
                System.out.println("Osoba o numerze PESEL " + peselNoTextField.getText() + " jest "+response);
        		setVerificationIconLabel();
                System.out.println("checkBtn clicked.");
            }
        });
    }

    private void setVerificationIconLabel() {
        verificationIconLabel.removeAll();
        if (result) verificationIconLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/autowus/gui/graphics/single/okay_128.png")));
        else verificationIconLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/autowus/gui/graphics/single/bad_128.png")));
        verificationIconLabel.repaint();
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        logoIconLabel = new javax.swing.JLabel();
        peselNoTextField = new javax.swing.JTextField();
        idTextField = new javax.swing.JTextField();
        checkBtn = new javax.swing.JButton();
        verificationIconLabel = new javax.swing.JLabel();
        copyrightLabel = new javax.swing.JLabel();

        setBackground(new java.awt.Color(2, 148, 75));
        setMaximumSize(new java.awt.Dimension(305, 530));
        setMinimumSize(new java.awt.Dimension(305, 530));
        setPreferredSize(new java.awt.Dimension(305, 530));

        logoIconLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        logoIconLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/autowus/gui/graphics/single/autoWUŚ_check_logo.png"))); // NOI18N
        logoIconLabel.setMaximumSize(new java.awt.Dimension(130, 76));
        logoIconLabel.setMinimumSize(new java.awt.Dimension(130, 76));
        logoIconLabel.setPreferredSize(new java.awt.Dimension(130, 76));

        peselNoTextField.setText("Pesel");
        peselNoTextField.setMargin(new java.awt.Insets(2, 13, 2, 13));
        peselNoTextField.setMaximumSize(new java.awt.Dimension(305, 55));
        peselNoTextField.setMinimumSize(new java.awt.Dimension(305, 55));
        peselNoTextField.setPreferredSize(new java.awt.Dimension(305, 55));
        peselNoTextField.addMouseListener(new MouseAdapter(){
        	@Override
        	public void mouseClicked(MouseEvent e){
        		peselNoTextField.setText("");
        	}
        });

        idTextField.setText("Numer dowodu");
        idTextField.setMargin(new java.awt.Insets(2, 13, 2, 13));
        idTextField.setMaximumSize(new java.awt.Dimension(305, 55));
        idTextField.setMinimumSize(new java.awt.Dimension(305, 55));
        idTextField.setPreferredSize(new java.awt.Dimension(305, 55));
        idTextField.addMouseListener(new MouseAdapter(){
        	@Override
        	public void mouseClicked(MouseEvent e){
        		idTextField.setText("");
        	}
        });

        checkBtn.setBackground(new java.awt.Color(53, 151, 212));
        checkBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/autowus/gui/graphics/single/autoWUŚ_check_check_one.png"))); // NOI18N
        checkBtn.setToolTipText("Wyślij do serwisu eWUŚ pojedyncze zapytanie.");
        checkBtn.setAlignmentX(0.5F);
        checkBtn.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        checkBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        checkBtn.setMargin(new java.awt.Insets(2, 2, 2, 2));
        checkBtn.setMaximumSize(new java.awt.Dimension(305, 55));
        checkBtn.setMinimumSize(new java.awt.Dimension(305, 55));
        checkBtn.setPreferredSize(new java.awt.Dimension(305, 55));
        checkBtn.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/autowus/gui/graphics/single/autoWUŚ_check_check_one_clicked.png"))); // NOI18N

        verificationIconLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        verificationIconLabel.setToolTipText("Ikona potwierdzająca wynik weryfikacji.");
        verificationIconLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        verificationIconLabel.setPreferredSize(new java.awt.Dimension(305, 207));

        copyrightLabel.setForeground(new java.awt.Color(255, 255, 255));
        copyrightLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        copyrightLabel.setText("<html><center>All rights reserved ® & Copyright © 2013<br>by Completely Unprepared</center></html>");
        copyrightLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        copyrightLabel.setMinimumSize(new java.awt.Dimension(57, 40));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(peselNoTextField, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(idTextField, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(checkBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(verificationIconLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addComponent(logoIconLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
            .addComponent(copyrightLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(logoIconLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(peselNoTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(idTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(checkBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(verificationIconLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(copyrightLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton checkBtn;
    private javax.swing.JLabel copyrightLabel;
    private javax.swing.JTextField idTextField;
    private javax.swing.JLabel logoIconLabel;
    private javax.swing.JTextField peselNoTextField;
    private javax.swing.JLabel verificationIconLabel;
    // End of variables declaration//GEN-END:variables
}
